package com.wind.base.subscriber;

import android.util.Log;

import com.wind.base.mvp.view.UploadFileView;
import com.wind.base.response.BaseResponse;
import com.wind.base.response.UploadFileResponse;

import rx.Observer;

public class UploadFileSubscriber implements Observer<UploadFileResponse> {
    private String TAG="UploadFileSubscriber";
    private UploadFileView mView;
    public UploadFileSubscriber(UploadFileView view){
        mView=view;
    }
    @Override
    public void onCompleted() {
        Log.e(TAG,"onCompleted");
        mView.onUploadFileReturn();
    }

    @Override
    public void onError(Throwable e) {
        Log.e(TAG,"onError");
        Log.i("haha","网络错误:"+e.getMessage().toString());
        mView.onUploadError("网络连接不可用，请检查网络");
    }

    @Override
    public void onNext(UploadFileResponse response) {
        Log.e(TAG,"onNext:");
        if (response.getErrCode() == BaseResponse.CODE_SUCCESS) {
            mView.onUploadFileProgress();
        }
    }
}
